]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
network: Deduplicate some similar code
authorJasper St. Pierre <jstpierre@mecheye.net>
Thu, 25 Apr 2013 20:24:14 +0000 (16:24 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Fri, 26 Apr 2013 16:16:06 +0000 (12:16 -0400)
https://bugzilla.gnome.org/show_bug.cgi?id=698918

js/ui/status/network.js

index 3f086b39f86c2c4e00591d15c5e605e8083337c0..cb524581797b7e11ea82905e8a831853e2645cf1 100644 (file)
@@ -2092,25 +2092,7 @@ const NMApplet = new Lang.Class({
         return false;
     },
 
-    _readConnections: function() {
-        let connections = this._settings.list_connections();
-        for (let i = 0; i < connections.length; i++) {
-            let connection = connections[i];
-            if (this._ignoreConnection(connection))
-                continue;
-            if (connection._updatedId) {
-                // connection was already seen (for example because NetworkManager was restarted)
-                continue;
-            }
-            connection._removedId = connection.connect('removed', Lang.bind(this, this._connectionRemoved));
-            connection._updatedId = connection.connect('updated', Lang.bind(this, this._updateConnection));
-
-            this._updateConnection(connection);
-            this._connections.push(connection);
-        }
-    },
-
-    _newConnection: function(settings, connection) {
+    _addConnection: function(connection) {
         if (this._ignoreConnection(connection))
             return;
         if (connection._updatedId) {
@@ -2123,7 +2105,15 @@ const NMApplet = new Lang.Class({
 
         this._updateConnection(connection);
         this._connections.push(connection);
+    },
 
+    _readConnections: function() {
+        let connections = this._settings.list_connections();
+        connections.forEach(Lang.bind(this, this._addConnection));
+    },
+
+    _newConnection: function(settings, connection) {
+        this._addConnection(connection);
         this._updateIcon();
     },